#include<iostream>
#include"HttpServer.hpp"

//测试传输大文件
int main()
{
    TcpSocket client;
    client.Build_Client_Socket(8888,"127.0.0.1");
    std::string req = "PUT /Test.txt HTTP/1.1\r\nConnection: keep-alive\r\n";
    std::string body; 
    Util::ReadFile("../Test_large.txt",&body);
    req+= "Content-Length: " + std::to_string(body.size())+"\r\n\r\n";
    req+= body;
    
    while(true){
        assert(client.Send(req.c_str(),req.size())!=-1);
        char buf[1024] = {0};
        assert(client.Recv(buf,1023));
        LOG_DBG("recv %s",buf);
        sleep(3);
    }
//     client.Close();
    return 0;
}


//测试错误处理
// int main()
// {
//     TcpSocket client;
//     client.Build_Client_Socket(8888,"127.0.0.1");
//     std::string req = "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 100\r\n\r\n106666";
//     while(true){
//         assert(client.Send(req.c_str(),req.size())!=-1);
//         assert(client.Send(req.c_str(),req.size())!=-1);
//         assert(client.Send(req.c_str(),req.size())!=-1);

//         char buf[1024];
//         assert(client.Recv(buf,1023));
//         LOG_DBG("recv %s",buf);
//         sleep(3);
//     }
//     client.Close();
//     return 0;
// }